﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class webLogin : System.Web.UI.Page
    {
        LogicUniversityT2Entities ct = new LogicUniversityT2Entities();
            protected void Page_Load(object sender, EventArgs e)
        {


        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {

      //    Session["username"] = txtUserName.Text.ToString();
            string n = txtUserName.Text.ToString();

            InventoryUser select = (from user in ct.InventoryUsers
                         where user.EmployeeID == n
                         select user).SingleOrDefault<InventoryUser>();

            


            Session["username"] = select;

           //    InventoryUser i = ct.InventoryUsers.First<InventoryUser>(cust => cust.EmployeeID == txtUserName.Text);
               
                if (select != null)
                {

                    if (select.Password.ToString() == txtPassword.Text.ToString())
                    {


                        if (select.Role.ToString() == "Head")

                            Response.Redirect("frmManageRequest.aspx");

                        if (select.Role.ToString() == "Employee")
                            Response.Redirect("frmRequestStationery.aspx");


                    }
                    else Label2.Text = "Wrong Password";



                }

             //   else Label2.Text = "null";
                
            } 

                
           
        }
        }
    
